package com.letv.core.parser;

import org.json.JSONException;
import org.json.JSONObject;

import com.letv.core.bean.IPBean;

/**
 * 海外IP接口解析
 * 
 * @author zhuqiao
 *
 */
public class IPParser extends LetvMasterParser<IPBean> {
    private final String CLIENT_IP = "clientIP";
    private final String USER_COUNTRY = "userCountry";

    @Override
    public IPBean parse(JSONObject data) throws JSONException {
        IPBean ip = new IPBean();

        ip.setClientIp(getString(data, CLIENT_IP));
        ip.setUserCountry(getString(data, USER_COUNTRY));

        return ip;
    }

    @Override
    protected boolean canParse(String data) {
        return true;
    }

    @Override
    protected JSONObject getData(String data) throws JSONException {
        return new JSONObject(data);
    }
}
